package cn.com.chengq.dictionary.client;

import cn.com.chengq.dictionary.DictionaryService;

public class DictionaryClient {
    public static void main(String[] args) {
        System.out.println("Load class: DictionaryClient by " + DictionaryClient.class.getClassLoader().getClass().getName());
        DictionaryService dictionary = DictionaryService.getInstance();
        for (String word : args) {
            System.out.println(lookup(dictionary, word));
        }
    }


    public static String lookup(DictionaryService dictionary, String word) {
        String definition = dictionary.getDefinition(word);
        return String.format("%s: %s", word, definition != null ? definition : "[Not found definition.]");
    }
}
